import { BaseInfoType, EventInfo, MenuToConfigMappingType } from '../../../framework/core/AbstractDefinition';
import { ClazzTemplate } from '../../common-component/CommonTypes';
import { MenuInfo } from '../../../designer/right/MenuType';
import baseColorBlockImg from './base-color-block.png';
import { BaseColorBlockController } from './BaseColorBlockController';
import { BaseColorBlockComponentProps } from './BaseColorBlockComponent';
import { BaseColorBlockConfig } from './BaseColorBlockConfig';
import React from 'react';
import AbstractDesignerDefinition from '../../../framework/core/AbstractDesignerDefinition';

const BaseInfo = React.lazy(() => import('../../common-component/base-info/BaseInfo'));
const ThemeConfig = React.lazy(() => import('../../common-component/theme-config/ThemeConfig'));
const AnimationConfig = React.lazy(() => import('../../common-component/animation-config/AnimationConfig'));
const FilterConfig = React.lazy(() => import('../../common-component/filter-config/FilterConfig'));

export default class BaseColorBlockDefinition extends AbstractDesignerDefinition<
  BaseColorBlockController,
  BaseColorBlockComponentProps
> {
  getBaseInfo(): BaseInfoType {
    return {
      compName: '基础色块',
      compKey: 'BaseColorBlock',
      categorize: 'ornament',
    };
  }

  getChartImg(): string | null {
    return baseColorBlockImg;
  }

  getController(): ClazzTemplate<BaseColorBlockController> | null {
    return BaseColorBlockController;
  }

  getInitConfig(): BaseColorBlockComponentProps {
    return {
      base: {
        id: '',
        name: '基础色块',
        type: 'BaseColorBlock',
      },
      style: {
        background: '#009DFF33',
        borderRadius: 0,
        borderWidth: 0,
        borderColor: '#74747400',
        borderStyle: 'none',
      },
      filter: {
        enable: false,
        blur: 0,
        brightness: 1,
        contrast: 1,
        opacity: 1,
        saturate: 1,
        hueRotate: 0,
      },
    };
  }

  getMenuList(): Array<MenuInfo> {
    return super
      .getMenuList()
      .filter((item: MenuInfo) => item.key !== 'theme' && item.key !== 'data' && item.key !== 'mapping');
  }

  getMenuToConfigContentMap(): MenuToConfigMappingType {
    return {
      base: BaseInfo,
      style: BaseColorBlockConfig,
      animation: AnimationConfig,
      theme: ThemeConfig,
      filter: FilterConfig,
    };
  }

  getEventList(): EventInfo[] {
    const events = super.getEventList();
    return events.concat([
      {
        id: 'click',
        name: '点击时',
      },
    ]);
  }
}
